<?php

/**
 * uniBoard ACP Permission Masks
 *
 * Light and fast forum solution for web 2.0-like communities.
 *
 * @package		uniBoard
 * @author		Rafał Pitoń
 * @license		http://www.gnu.org/licenses/gpl-3.0.html
 * @since		Version 0.1
 * 
 * ------------------------------------------------------------------------
 * 
 * $Date: 2010-09-08 03:38:35 +0000 (Wed, 08 Sep 2010) $
 * $Revision: 60 $
 * $Author: rafio.xudb@gmail.com $
 */

// ------------------------------------------------------------------------

class action_masks{
	
	/**
	 * Main class pointer
	 *
	 * @var object
	 */
	
	private $appCore		= NULL;
	
	// ------------------------------------------------------------------------

	/**
	 * Initialise Action
	 *
	 * @param object $appCore
	 */
	
	function __construct( $appCore){
		
		// Store appCore pointer
		$this -> appCore = $appCore;
		
		// Cache output
		ob_start();
		
		// Open table block
		echo $appCore -> output -> openTableBlock();
		
		// Draw header
		echo $appCore -> output -> tableHeader( array(
			array(
				'left_float width_longer',
				$appCore -> lang['acp_mask_list_name']
			),
			array(
				'right_float width_medium',
				$appCore -> lang['actions']
			)
		));
				
		// Select Masks
		$appCore -> db -> query( 'SELECT mask_id, mask_name
		FROM ' . DB_PREFIX . 'permission_masks
		ORDER BY mask_name');
		
		// Parse result
		while ( $mask_result = $appCore -> db -> fetch_array())
		{
			// Draw row
			echo $appCore -> output -> tableRow('
				<div class="cell left_float width_longer">
					<b>' . $appCore -> ifString( htmlspecialchars( $mask_result[1])) . '</b>
				</div>
				<div class="cell left_border right_float width_medium">
					' . $appCore -> output -> toolsPopup('<a href="' . $appCore -> adminLink( 'act=edit_mask&do=name&mask=' . $mask_result[0]) . '">' . $appCore -> output -> drawImage( 'action_edit', $appCore -> lang['acp_mask_op_rename']) . ' ' . $appCore -> lang['acp_mask_op_rename'] . '</a>
<a href="' . $appCore -> adminLink( 'act=edit_mask&do=copy&mask=' . $mask_result[0]) . '">' . $appCore -> output -> drawImage( 'action_copy', $appCore -> lang['acp_mask_op_copy']) . ' ' . $appCore -> lang['acp_mask_op_copy'] . '</a>
<a href="' . $appCore -> adminLink( 'act=edit_mask&do=main&mask=' . $mask_result[0]) . '">' . $appCore -> output -> drawImage( 'action_permissions', $appCore -> lang['acp_mask_op_perms_main']) . ' ' . $appCore -> lang['acp_mask_op_perms_main'] . '</a>
<a href="' . $appCore -> adminLink( 'act=edit_mask&do=forums&mask=' . $mask_result[0]) . '">' . $appCore -> output -> drawImage( 'action_permissions', $appCore -> lang['acp_mask_op_perms_forums']) . ' ' . $appCore -> lang['acp_mask_op_perms_forums'] . '</a>
<a href="' . $appCore -> adminLink( 'act=edit_mask&do=delete&mask=' . $mask_result[0]) . '">' . $appCore -> output -> drawImage( 'action_delete', $appCore -> lang['acp_mask_op_delete']) . ' ' . $appCore -> lang['acp_mask_op_delete'] . '</a>') . '
				</div>');
		}
		
		// Free result
		$appCore -> db -> freeResult();
		
		// Close table block
		echo $appCore -> output -> closeTableBlock();
		
		// Draw output
		$appCore -> output -> draw( $appCore -> lang['acp_access_masks'], array( $appCore -> adminLink( 'act=masks') => $appCore -> lang['acp_access_masks']), ob_get_clean());
				
	}

}